package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.service.store.awk.bean.HorizontalPromoteAppItemCardBean;
import com.huawei.appmarket.service.store.awk.bean.HorizontalPromoteProductCardBean;
import huawei.widget.HwTextView;
import o.cgz;
import o.chc;
import o.chy;
import o.eib;
import o.epv;
import o.epw;
import o.eqx;
import o.evf;
import o.evx;
import o.ewm.e;
import o.ewm.h;
import o.ewm.i;
import o.ewm.j;

public class HorizontalPromoteAppItemCard extends BaseHorizontalItemCard {
    private HwTextView ʻ;
    private HwTextView ʼ;
    private RelativeLayout ʽ;
    private RelativeLayout ˊॱ;
    private ImageView ˋ;
    private HorizontalPromoteProductCard ˋॱ;
    private HorizontalPromoteProductCard ˏॱ;
    private LinearLayout ͺ;
    private RelativeLayout ॱˊ;
    private LinearLayout ॱॱ;
    private HorizontalPromoteProductCard ॱᐝ;
    private RelativeLayout ᐝ;

    public /* synthetic */ CardBean ˌ() {
        return ॱॱ();
    }

    public HorizontalPromoteAppItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˋ((DownloadButton) view.findViewById(j.ⁱᐝ));
        this.ˋ = (ImageView) view.findViewById(j.ₗॱ);
        this.ʼ = (HwTextView) view.findViewById(j.ᶺ);
        this.ʻ = (HwTextView) view.findViewById(j.ⁱˊ);
        this.ॱॱ = (LinearLayout) view.findViewById(j.ₜ);
        this.ʽ = (RelativeLayout) view.findViewById(j.ⁱˋ);
        this.ͺ = (LinearLayout) view.findViewById(j.ㆍʻ);
        this.ᐝ = (RelativeLayout) view.findViewById(j.Ꞌ);
        this.ˋॱ = new HorizontalPromoteProductCard(this.ʼॱ);
        this.ˋॱ.ˏ(this.ᐝ);
        this.ˊॱ = (RelativeLayout) view.findViewById(j.ʼᴵ);
        this.ˏॱ = new HorizontalPromoteProductCard(this.ʼॱ);
        this.ˏॱ.ˏ(this.ˊॱ);
        this.ॱˊ = (RelativeLayout) view.findViewById(j.ʿꞌ);
        this.ॱᐝ = new HorizontalPromoteProductCard(this.ʼॱ);
        this.ॱᐝ.ˏ(this.ॱˊ);
        ʽ(view);
        ʼ();
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof HorizontalPromoteAppItemCardBean) {
            HorizontalPromoteAppItemCardBean horizontalPromoteAppItemCardBean = (HorizontalPromoteAppItemCardBean) cardBean;
            this.ʼ.setText(horizontalPromoteAppItemCardBean.v_());
            ॱ(horizontalPromoteAppItemCardBean);
            ˊ(horizontalPromoteAppItemCardBean);
            ˏ(horizontalPromoteAppItemCardBean);
            ˋ(horizontalPromoteAppItemCardBean);
        }
    }

    private void ॱ(HorizontalPromoteAppItemCardBean horizontalPromoteAppItemCardBean) {
        if (TextUtils.isEmpty(horizontalPromoteAppItemCardBean.ॱˑ())) {
            eqx.ˏ(this.ˋ, horizontalPromoteAppItemCardBean.ॱˌ(), "app_default_icon");
        } else {
            eqx.ॱ(this.ˋ, horizontalPromoteAppItemCardBean.ॱˑ(), "app_default_icon");
        }
        this.ˋ.setContentDescription(horizontalPromoteAppItemCardBean.v_());
    }

    private void ˋ(HorizontalPromoteAppItemCardBean horizontalPromoteAppItemCardBean) {
        for (int i = 0; i < horizontalPromoteAppItemCardBean.ʻˊ().size(); i++) {
            CardBean cardBean = (HorizontalPromoteProductCardBean) horizontalPromoteAppItemCardBean.ʻˊ().get(i);
            cardBean.ॱ(ॱॱ().ʼˊ());
            switch (i) {
                case 0:
                    this.ˋॱ.ˏ(cardBean);
                    break;
                case 1:
                    this.ˏॱ.ˏ(cardBean);
                    break;
                case 2:
                    this.ॱᐝ.ˏ(cardBean);
                    break;
                default:
                    break;
            }
        }
    }

    private void ˊ(HorizontalPromoteAppItemCardBean horizontalPromoteAppItemCardBean) {
        this.ʻ.setText(this.ʼॱ.getResources().getQuantityString(i.ʼॱ, horizontalPromoteAppItemCardBean.ʼˋ(), new Object[]{Integer.valueOf(horizontalPromoteAppItemCardBean.ʼˋ())}));
    }

    private void ʼ() {
        int ˋ = chc.ˋ();
        LayoutParams layoutParams = this.ॱॱ.getLayoutParams();
        layoutParams.width = epv.ˎ(this.ʼॱ, eib.ˋॱ(), ˋ);
        this.ॱॱ.setLayoutParams(layoutParams);
    }

    private void ˏ(HorizontalPromoteAppItemCardBean horizontalPromoteAppItemCardBean) {
        int size = horizontalPromoteAppItemCardBean.ʻˊ().size();
        if (size > 0) {
            this.ᐝ.setVisibility(0);
        } else {
            this.ᐝ.setVisibility(4);
        }
        if (size > 1) {
            this.ˊॱ.setVisibility(0);
        } else {
            this.ˊॱ.setVisibility(4);
        }
        if (size > 2) {
            this.ॱˊ.setVisibility(0);
        } else {
            this.ॱˊ.setVisibility(4);
        }
    }

    public HorizontalPromoteAppItemCardBean ॱॱ() {
        if (this.ˊᐝ instanceof HorizontalPromoteAppItemCardBean) {
            return (HorizontalPromoteAppItemCardBean) this.ˊᐝ;
        }
        return null;
    }

    public void ᐝ(int i) {
        if (i % 3 == 0) {
            ˊ(evf.ˋ(this.ʼॱ, e.ˊॱ));
        } else if (i % 3 == 1) {
            ˊ(evf.ˋ(this.ʼॱ, e.ˏॱ));
        } else if (i % 3 == 2) {
            ˊ(evf.ˋ(this.ʼॱ, e.ˋॱ));
        }
    }

    private void ˊ(Drawable drawable) {
        if (epw.ˏ()) {
            drawable.setAlpha(51);
        } else {
            drawable.setAlpha(255);
        }
        this.ॱॱ.setBackground(drawable);
    }

    public int ˊ() {
        return h.ˋʼ;
    }

    public int ˎ() {
        return h.ˋʼ;
    }

    public void ॱ(final chy o_chy) {
        this.ˋॱ.ॱ(o_chy);
        this.ˏॱ.ॱ(o_chy);
        this.ॱᐝ.ॱ(o_chy);
        this.ʽ.setOnClickListener(new evx(this) {
            final /* synthetic */ HorizontalPromoteAppItemCard ˎ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˎ);
            }
        });
        this.ͺ.setOnClickListener(new evx(this) {
            final /* synthetic */ HorizontalPromoteAppItemCard ˎ;

            public void ˋ(View view) {
                String ॱॱ = this.ˎ.ॱॱ().ॱॱ();
                this.ˎ.ॱॱ().ॱ(this.ˎ.ॱॱ().ʼˊ());
                o_chy.ˏ(0, this.ˎ);
                this.ˎ.ॱॱ().ॱ(ॱॱ);
            }
        });
    }
}
